# Maintainer: Miloš Komarčević <miloskomarcevic@aim.com>

_realname=webp-pixbuf-loader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.0.7
pkgrel=1
pkgdesc="WebP GDK Pixbuf Loader library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://github.com/aruiz/webp-pixbuf-loader"
license=('spdx:LGPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-meson")
depends=("${MINGW_PACKAGE_PREFIX}-libwebp"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/aruiz/webp-pixbuf-loader/archive/${pkgver}.tar.gz")
sha256sums=('121bcb564c6908a8681281766f7c5941d09b5ec0b7b55b9212f1e832d637d3e7')

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe \
      --prefix=${MINGW_PREFIX} \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      "../${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson.exe install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.LGPL-2" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
